﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

    <!-- Resource dictionary entries should be defined here. -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="CalendarItemStyle" TargetType="{x:Type CalendarItem}">
        <Setter Property="Margin" Value="0,3,0,3" />
        <Setter Property="Template" Value="{DynamicResource CalendarItemTemplate}"/>
    </Style>
    
    <!--Style for the days of a month.-->
    <Style TargetType="{x:Type CalendarDayButton}" x:Key="CalendarDayButtonStyle">
        <Setter Property="MinWidth" Value="5" />
        <Setter Property="MinHeight" Value="5" />
        <Setter Property="FontSize" Value="10" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template" Value="{DynamicResource CalendarDayButtonTemplate}" />
    </Style>

    <!--Style for the months of a year and years of a decade.-->
    <Style TargetType="CalendarButton" x:Key="CalendarButtonStyle">
        <Setter Property="MinWidth" Value="40" />
        <Setter Property="MinHeight" Value="42" />
        <Setter Property="FontSize" Value="10" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template" Value="{DynamicResource CalendarButtonTemplate}"/>
    </Style>

    <Style TargetType="{x:Type Calendar}">
        <Setter Property="CalendarButtonStyle" Value="{StaticResource CalendarButtonStyle}" />
        <Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonStyle}" />
        <Setter Property="CalendarItemStyle" Value="{StaticResource CalendarItemStyle}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Calendar}">
                    <StackPanel x:Name="PART_Root" HorizontalAlignment="Center">
                        <CalendarItem x:Name="PART_CalendarItem" Style="{TemplateBinding CalendarItemStyle}" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="CalendarDayButtonTemplate" TargetType="{x:Type CalendarDayButton}">
        <Grid>
    		<VisualStateManager.VisualStateGroups>
    			<VisualStateGroup x:Name="CommonStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="Normal" GeneratedDuration="0:0:0.3" To="MouseOver"/>
    					<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.3" To="Normal"/>
    					<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Pressed"/>
    					<VisualTransition From="Pressed" GeneratedDuration="0:0:0.2" To="MouseOver"/>
    					<VisualTransition From="Pressed" GeneratedDuration="0:0:0.3" To="Normal"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Normal" />
    				<VisualState x:Name="MouseOver">
    					<Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Move}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Move}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Pressed">
    					<Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Pressed}" />
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Pressed}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Disabled">
    					<Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Disabled}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Disabled}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="SelectionStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition GeneratedDuration="0" />
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Unselected" />
    				<VisualState x:Name="Selected">
    					<Storyboard>
    						<DoubleAnimation Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0" From="0" />
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="CalendarButtonFocusStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition GeneratedDuration="0" />
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="CalendarButtonFocused">
    					<Storyboard RepeatBehavior="Forever" AutoReverse="True">
    						<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DayButtonFocusVisual" Storyboard.TargetProperty="Visibility" Duration="0">
    							<DiscreteObjectKeyFrame KeyTime="0">
    								<DiscreteObjectKeyFrame.Value>
    									<Visibility>Visible</Visibility>
    								</DiscreteObjectKeyFrame.Value>
    							</DiscreteObjectKeyFrame>
    							<DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Visible}"/>
    						</ObjectAnimationUsingKeyFrames>
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DayButtonFocusVisual">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    							<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.5"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="CalendarButtonUnfocused"/>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="ActiveStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition GeneratedDuration="0" />
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Active" />
    				<VisualState x:Name="Inactive">
    					<Storyboard>
                            <DoubleAnimation Storyboard.TargetName="NormalText" Storyboard.TargetProperty="Opacity" To=".35" Duration="0" />
                        </Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="DayStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition GeneratedDuration="0" />
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="RegularDay" />
    				<VisualState x:Name="Today">
    					<Storyboard>
    						<DoubleAnimation Storyboard.TargetName="TodayBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="BlackoutDayStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition GeneratedDuration="0" />
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="NormalDay" />
    				<VisualState x:Name="BlackoutDay">
    					<Storyboard>
    						<DoubleAnimation Duration="0" Storyboard.TargetName="Blackout" Storyboard.TargetProperty="Opacity" To="0.75" />
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="FocusStates">
    				<VisualState x:Name="Unfocused"/>
    				<VisualState x:Name="Focused"/>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="ValidationStates">
    				<VisualState x:Name="Valid"/>
    				<VisualState x:Name="InvalidFocused"/>
    				<VisualState x:Name="InvalidUnfocused"/>
    			</VisualStateGroup>
    		</VisualStateManager.VisualStateGroups>
    		<Border x:Name="border" BorderThickness="0" CornerRadius="2" >
    			<Border.Background>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_Background}"/>
    			</Border.Background>
    		</Border>
    		<Rectangle x:Name="TodayBackground" RadiusX="2" RadiusY="2" Opacity="0">
    			<Rectangle.Stroke>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_BorderBrush_Selection}"/>
    			</Rectangle.Stroke>
    			<Rectangle.Fill>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_Background_Selection}" />
    			</Rectangle.Fill>
    		</Rectangle>
    		<Rectangle x:Name="SelectedBackground" RadiusX="2" RadiusY="2" Opacity="0">
    			<Rectangle.Stroke>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_BorderBrush_Selection}"/>
    			</Rectangle.Stroke>
    			<Rectangle.Fill>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_Background_Selection}" />
    			</Rectangle.Fill>
    		</Rectangle>
    		<Rectangle x:Name="HighlightBackground" RadiusX="1" RadiusY="1" Opacity="0">
    			<Rectangle.Fill>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_Background_Move}" />
    			</Rectangle.Fill>
    		</Rectangle>
    		<ContentPresenter x:Name="NormalText" Margin="5,1,5,1" HorizontalAlignment="Center" VerticalAlignment="Center">
    			<TextElement.Foreground>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_Foreground}" />
    			</TextElement.Foreground>
    		</ContentPresenter>
    		<Path x:Name="Blackout" Opacity="0" Margin="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Stretch="Fill"
    			  Data="M8.1772461,11.029181 L10.433105, 11.029181 L11.700684,12.801641 L12.973633, 11.029181 L15.191895,11.029181 L12.844727, 13.999395 L15.21875,17.060919 L12.962891, 17.060919 L11.673828,15.256231 L10.352539, 17.060919 L8.1396484,17.060919 L10.519043, 14.042364 z" >
    			<Path.Fill>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_Background_Pressed}"/>
    			</Path.Fill>
    		</Path>
    		<Rectangle x:Name="DayButtonFocusVisual" Visibility="Collapsed" IsHitTestVisible="false" RadiusX="2" RadiusY="2">
    			<Rectangle.Stroke>
    				<SolidColorBrush Color="{StaticResource Application_Calendar_Button_BorderBrush_Focus}" />
    			</Rectangle.Stroke>
    		</Rectangle>
    	</Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="CalendarButtonTemplate" TargetType="CalendarButton">
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition From="Normal" GeneratedDuration="0:0:0.3" To="MouseOver"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.3" To="Normal"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Pressed"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.2" To="MouseOver"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.3" To="Normal"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal" />
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Move}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Move}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Pressed}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Pressed}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Disabled}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Disabled}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup Name="SelectionStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0" />
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Unselected" />
                    <VisualState x:Name="Selected">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0" From="0" />
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup Name="ActiveStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0" />
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Active" />
                    <VisualState x:Name="Inactive">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="NormalText" Storyboard.TargetProperty="Opacity" To=".35" Duration="0" />
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup Name="CalendarButtonFocusStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0" />
                    </VisualStateGroup.Transitions>
                    <VisualState Name="CalendarButtonFocused">
                        <Storyboard RepeatBehavior="Forever" AutoReverse="True">
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CalendarButtonFocusVisual" Storyboard.TargetProperty="Visibility" Duration="0">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                                <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Visible}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="CalendarButtonFocusVisual">
                                <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.5"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState Name="CalendarButtonUnfocused" />
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="border" BorderThickness="0" CornerRadius="2" >
                <Border.Background>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Button_Background}"/>
                </Border.Background>
            </Border>
            <Rectangle x:Name="SelectedBackground" RadiusX="2" RadiusY="2" Opacity="0">
                <Rectangle.Stroke>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Button_BorderBrush_Selection}"/>
                </Rectangle.Stroke>
                <Rectangle.Fill>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Button_Background_Selection}" />
                </Rectangle.Fill>
            </Rectangle>
            <ContentPresenter x:Name="NormalText" Margin="1,0,1,1" HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextElement.Foreground>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Button_Foreground}" />
                </TextElement.Foreground>
            </ContentPresenter>
            <Rectangle x:Name="CalendarButtonFocusVisual" Visibility="Collapsed" IsHitTestVisible="false" RadiusX="2" RadiusY="1">
                <Rectangle.Stroke>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Button_BorderBrush_Focus}" />
                </Rectangle.Stroke>
            </Rectangle>
        </Grid>
    </ControlTemplate>

    <!--Button to go to the previous month or year.-->
    <ControlTemplate x:Key="PreviousButtonTemplate" TargetType="{x:Type Button}">
        <Grid Cursor="Hand">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition From="Normal" GeneratedDuration="0:0:0.3" To="MouseOver"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.3" To="Normal"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Pressed"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.2" To="MouseOver"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.3" To="Normal"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal" />
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                            To="{DynamicResource Application_Calendar_Button_Foreground_Move}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Move}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                            To="{DynamicResource Application_Calendar_Button_Foreground_Pressed}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Pressed}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                            To="{DynamicResource Application_Calendar_Button_Foreground_Disabled}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Disabled}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="border" BorderThickness="0" CornerRadius="2" >
                <Border.Background>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Header_Background}"/>
                </Border.Background>
            </Border>
            <Grid Background="Transparent">
                <Path x:Name="path" Margin="14,0,0,0" Stretch="Fill" HorizontalAlignment="Left" Height="10" VerticalAlignment="Center"
                      Width="6" Data="M288.75,232.25 L288.75,240.625 L283,236.625 z">
                    <Path.Fill>
                        <SolidColorBrush Color="{StaticResource Application_Calendar_Button_Foreground}" />
                    </Path.Fill>
                </Path>
            </Grid>
        </Grid>
    </ControlTemplate>

    <!--Button to go to the next month or year.-->
    <ControlTemplate x:Key="NextButtonTemplate" TargetType="{x:Type Button}">
        <Grid Cursor="Hand">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition From="Normal" GeneratedDuration="0:0:0.3" To="MouseOver"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.3" To="Normal"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Pressed"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.2" To="MouseOver"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.3" To="Normal"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal" />
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                            To="{DynamicResource Application_Calendar_Button_Foreground_Move}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Move}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                            To="{DynamicResource Application_Calendar_Button_Foreground_Pressed}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Pressed}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                            To="{DynamicResource Application_Calendar_Button_Foreground_Disabled}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Disabled}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="border" BorderThickness="0" CornerRadius="2" >
                <Border.Background>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Header_Background}"/>
                </Border.Background>
            </Border>
            <Grid Background="Transparent">
                <Path x:Name="path" Data="M282.875,231.875 L282.875,240.375 L288.625,236 z" HorizontalAlignment="Right" Height="10"
                      Margin="0,0,14,0" Stretch="Fill" VerticalAlignment="Center" Width="6">
                    <Path.Fill>
                        <SolidColorBrush Color="{StaticResource Application_Calendar_Button_Foreground}" />
                    </Path.Fill>
                </Path>
            </Grid>
        </Grid>
    </ControlTemplate>

    <!--Button to go up a level to the year or decade.-->
    <ControlTemplate x:Key="HeaderButtonTemplate" TargetType="{x:Type Button}">
        <Grid Cursor="Hand">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup Name="CommonStates">
                    <VisualStateGroup.Transitions>
                        <VisualTransition From="Normal" GeneratedDuration="0:0:0.3" To="MouseOver"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.3" To="Normal"/>
                        <VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Pressed"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.2" To="MouseOver"/>
                        <VisualTransition From="Pressed" GeneratedDuration="0:0:0.3" To="Normal"/>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal" />
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Move}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Move}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Pressed}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Pressed}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ColorAnimation Duration="0" Storyboard.TargetName="NormalText" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
    							            To="{DynamicResource Application_Calendar_Button_Foreground_Disabled}" />
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Calendar_Button_Background_Disabled}"/>
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="border" BorderThickness="0" CornerRadius="2" >
                <Border.Background>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Header_Background}"/>
                </Border.Background>
            </Border>
            <ContentPresenter x:Name="NormalText" Margin="1,0" ContentTemplate="{TemplateBinding ContentTemplate}"
                              Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                <TextElement.Foreground>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Button_Foreground}" />
                </TextElement.Foreground>
            </ContentPresenter>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="CalendarItemTemplate" TargetType="{x:Type CalendarItem}">
        <ControlTemplate.Resources>
            <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
                <TextBlock FontWeight="Bold" FontSize="9.5" FontFamily="Verdana" Margin="0,6,0,6" Text="{Binding}" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <TextBlock.Foreground>
                        <SolidColorBrush Color="{StaticResource Application_Calendar_Foreground}" />
                    </TextBlock.Foreground>
                </TextBlock>
            </DataTemplate>
        </ControlTemplate.Resources>
        <Grid x:Name="PART_Root">
            <Border BorderThickness="1" CornerRadius="2">
                <Border.BorderBrush>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_BorderBrush}" />
                </Border.BorderBrush>
                <Border.Background>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Background}" />
                </Border.Background>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Button x:Name="PART_PreviousButton" Template="{StaticResource PreviousButtonTemplate}" Focusable="False" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Height="25" Width="25" Grid.ColumnSpan="1" Margin="0" />
                    <Button x:Name="PART_HeaderButton" FontWeight="Bold" Focusable="False" FontSize="10.5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Template="{StaticResource HeaderButtonTemplate}" Grid.ColumnSpan="1" />
                    <Button x:Name="PART_NextButton" Focusable="False" HorizontalAlignment="Stretch" Grid.Column="2" Grid.Row="0" Template="{StaticResource NextButtonTemplate}" Height="25" Width="25" Margin="0" />
                    <Grid x:Name="PART_MonthView" Visibility="Visible" Grid.ColumnSpan="3" Grid.Row="1" Margin="6" HorizontalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                    </Grid>
                    <Grid x:Name="PART_YearView" Visibility="Hidden" Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Margin="6">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                    </Grid>
                </Grid>
            </Border>
            <Rectangle x:Name="PART_DisabledVisual" Opacity="1" RadiusY="2" RadiusX="2" Stretch="Fill" Visibility="Collapsed">
                <Rectangle.Fill>
                    <SolidColorBrush Color="{StaticResource Application_Calendar_Background_Disabled}" />
                </Rectangle.Fill>
            </Rectangle>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Visibility" TargetName="PART_DisabledVisual" Value="Visible" />
            </Trigger>
            <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Year">
                <Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
                <Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
            </DataTrigger>
            <DataTrigger Binding="{Binding DisplayMode,  RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Decade">
                <Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
                <Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

</ResourceDictionary>